2 Samuel depicts David as the true (though not entirely perfect) representative of the ideal theocratic king; a king who would genuinely rule for God. In the course of David's reign, God makes a promise to David. Israel will always have a king from David's family. David's throne will be established forever.
2 Samuel 7:12-13 "When your days are over and you rest with your fathers, I will raise up your offspring to succeed you, who will come from your own body, and I will establish his kingdom. He is the one who will build a house for my Name, and I will establish the throne of his kingdom forever."
2 Samuel 7:16 "Your house and your kingdom will endure forever before me; your throne will be established forever."